<script setup lang="ts">
import { useSite } from './stores/site';
import { useUserStore } from './stores/user';
import { delUrlParam } from './utils/helpers';

onLaunch((options: any) => {
  if (options?.query?.token) {
    uni.setStorageSync('token', options.query.token)
    // 替换token
    delUrlParam('token')
  }
  if (options?.query?.appid) {
    uni.setStorageSync('appid',options.query.appid)
  }
  if (options?.query?.icode) {
    uni.setStorageSync('icode',options.query.icode)
  }
  // 初始化项目信息
  useSite().getInfo();
  // 初始化用户信息
  useUserStore().getUserInfo()
  
  // 监听用户信息更新
  uni.$on('user::update', () => {
    useUserStore().getUserInfo();
  })
  // 监听站点信息更新
  uni.$on('site::update',()=>{
    useSite().getInfo();
  })
});
onShow(() => { });
onHide(() => { });
</script>
<style lang="scss">
@import "uview-plus/index.scss";
@import "static/global.scss";
@import "static/iconfont.css";

page {
  height: 100%;
  background: #F4F4F4;
}
</style>
